home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pp / pp-6.0 / Format / asn / asn_rd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-18  |  2.1 KB  |  127 lines

  1. /* asn_rd.c - reads ASN from stdin */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Format/asn/RCS/asn_rd.c,v 6.0 1991/12/18 20:15:43 jpo Rel $";
  5. # endif
  6.  
  7. /*
  8.  * $Header: /xtel/pp/pp-beta/Format/asn/RCS/asn_rd.c,v 6.0 1991/12/18 20:15:43 jpo Rel $
  9.  *
  10.  * $Log: asn_rd.c,v $
  11.  * Revision 6.0  1991/12/18  20:15:43  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16.  
  17.  
  18. #include    "head.h"
  19. #include    "asn.h"
  20.  
  21.  
  22.  
  23. extern PE    ps2pe_aux();
  24.  
  25.  
  26.  
  27.  
  28. /* ------------------------  Start Routine  --------------------------------- */
  29.  
  30.  
  31.  
  32.  
  33. PE asn_rd_stdin (flag)
  34. int    flag;
  35. {
  36.     register PE    pe;
  37.     register PS    ps;
  38.  
  39.  
  40.     PP_TRACE (("asn_rd_stdin()"));
  41.  
  42.     if ((ps = ps_alloc(std_open)) == NULLPS) {
  43.         PP_LOG(LLOG_EXCEPTIONS, ("Error: ps_alloc(std_open)"));
  44.         exit(1);
  45.     }
  46.  
  47.     if (std_setup(ps, stdin) == NOTOK) {
  48.         PP_LOG(LLOG_EXCEPTIONS, ("Error: std_setup()"));
  49.         exit(1);
  50.     }
  51.  
  52.  
  53.     if (flag == IGNORE_PRMS)
  54.         ignore_parameters (ps);
  55.  
  56.  
  57.     if ((pe = ps2pe(ps)) == NULLPE) {
  58.         if (ps->ps_errno)
  59.             PP_LOG(LLOG_EXCEPTIONS, ("Error: ps2pe: %s", 
  60.                         ps_error(ps->ps_errno)));
  61.         else
  62.             PP_LOG(LLOG_EXCEPTIONS, ("Error: ps2pe()")); 
  63.  
  64.         exit(1);    
  65.     }
  66.  
  67.     ps_free(ps);
  68.     return pe;
  69. }
  70.  
  71.  
  72.  
  73.  
  74. /* ------------------------  Static Routines  ------------------------------- */
  75.  
  76.  
  77.  
  78.  
  79. static int ignore_parameters (psin)
  80. PS    psin;
  81. {
  82.  
  83.     PE    pe;
  84.  
  85.     PP_TRACE (("ignore_parameters()"));
  86.  
  87.     if ((pe = ps2pe_aux (psin, 1, 0)) == NULLPE) {
  88.         PP_LOG(LLOG_EXCEPTIONS,
  89.             ("Error: ps2pe_aux reading SEQUENCE info failed [%s]",
  90.             ps_error(psin -> ps_errno)));
  91.         exit (1);
  92.     }
  93.  
  94.  
  95. #ifdef DEBUG
  96.     (void) testdebug (pe, "asnfilter/ignore_parameters (BEGIN)"); 
  97. #endif
  98.  
  99.     PP_TRACE (("Ignoring (class=%d, id=%d)", pe -> pe_class, pe -> pe_id));
  100.     pe_free (pe);
  101.  
  102.  
  103.     if ((pe = ps2pe_aux (psin, 1, 0)) == NULLPE) {
  104.         PP_LOG(LLOG_EXCEPTIONS,
  105.             ("Error: ps2pe_aux reading SET info failed [%s]",
  106.             ps_error(psin -> ps_errno)));
  107.         exit (1);
  108.     }
  109.  
  110.  
  111.  
  112. #ifdef DEBUG
  113.     (void) testdebug (pe, "asnfilter/ignore_parameters (SET)");
  114. #endif
  115.  
  116.  
  117.     if (PE_ID(pe -> pe_class, pe -> pe_id) !=
  118.         PE_ID(PE_CLASS_UNIV, PE_CONS_SET)) {
  119.         PP_LOG(LLOG_EXCEPTIONS, ("Unexpected pe: expected a SET"));
  120.         exit (1);
  121.     }
  122.  
  123.  
  124.     PP_TRACE (("Ignoring (class=%d, id=%d)", pe -> pe_class, pe -> pe_id));
  125.     pe_free (pe);
  126. }
  127.